package com.jsyh.maidu.activity.me;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.jsyh.maidu.R;
import com.jsyh.maidu.activity.BaseActivity;
import com.jsyh.maidu.adapter.StoreClassAdapter;
import com.jsyh.maidu.model.StoreClassModel;
import com.jsyh.maidu.presenter.StoreClassPresenter;
import com.jsyh.maidu.views.StoreClassView;

/**
 * Created by admin on 2017/7/17.
 */

public class StoryClassActivity extends BaseActivity implements StoreClassView{

    ListView lv_class;
    TextView tv_title;
    ImageView iv_back;
    StoreClassPresenter presenter;
    StoreClassAdapter adapter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_story_class);

        lv_class= (ListView) findViewById(R.id.lv_storyclass);
        adapter=new StoreClassAdapter(mContext,getIntent().getStringExtra("suppid"),R.layout.item_store_class);
        tv_title= (TextView) findViewById(R.id.title);
        iv_back= (ImageView) findViewById(R.id.back);
        tv_title.setText("商品分类");
        iv_back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
        lv_class.setAdapter(adapter);

    }

    @Override
    public void initData() {
        super.initData();
        presenter=new StoreClassPresenter(this,mContext);
        presenter.loadStoreClass(getIntent().getStringExtra("suppid"));

    }

    @Override
    public void returnStoreClss(StoreClassModel model) {
        if (model.getCode().equals("1") &&  model.getData().size()!=0)
        {
           adapter.addAll(model.getData());
        }
    }
}
